﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ClientApplication
{
    public partial class Admin5 : Form, IAdmin5
    {
        public Admin5()
        {
            InitializeComponent();
        }

        private void textBox4_TextChanged(object sender, EventArgs e)
        {

        }

        public void PrintContestantDetails(ContestPacket cPacket, int contestantId)
        {
            listView_resultView.Items.Clear();
            textBox_Rank.Text = contestantId.ToString();
            textBox_Name.Text = cPacket.contest.contestantList[contestantId - 1].name;
            textBox_Nationality.Text = cPacket.contest.contestantList[contestantId - 1].nationality;
            textBox_TotalScore.Text = cPacket.contest.contestantList[contestantId - 1].totalScore.ToString();

            for (int i = 0; i < 7; i++)
            {
                listView_resultView.Columns[3 + i].Text = "";
            }

            for (int i = 0; i < cPacket.judges.Count; i++)
            {
                listView_resultView.Columns[3 + i].Text = cPacket.judges[i].username;
            }
            
            for (int i = 0; i < cPacket.contest.contestantList.contestants[contestantId - 1].jumps.Count; i++)
            {
                ListViewItem newItem = new ListViewItem((i + 1).ToString());
                newItem.SubItems.Add(cPacket.contest.contestantList.contestants[contestantId - 1].jumps[i].typeOfJump);
                newItem.SubItems.Add(cPacket.contest.contestantList.contestants[contestantId - 1].jumps[i].totalScore.ToString());


                for (int x = 0; x < cPacket.judges.Count; x++)
                {
                    for (int z = 0; z < cPacket.judges.Count; z++)
                    {
                        if (listView_resultView.Columns[3 + x].Text == cPacket.contest.contestantList.contestants[contestantId - 1].jumps[i].judgesScore[z].id)
                        {
                            newItem.SubItems.Add(cPacket.contest.contestantList.contestants[contestantId - 1].jumps[i].judgesScore[z].score.ToString());
                        }
                    }
                }
                listView_resultView.Items.Add(newItem);
            }
        }
    }
}
